<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="include :: header(供电所名单修改)"/>
</head>
<style>
    .layui-input{height:30px;} /* layui-input 默认太高了，这里固定高度*/
    label.required:after {   /* 给红色的必填项打红色星号（文字后）如果打前面用before*/
        content: ' *';
        color: red;
    }
</style>
<body>
<form action="" class="layui-form" th:object="${RpaTask}">
    <div class="mainBox">
        <div class="main-container">
            <div class="main-container">
                <div class="layui-form-item layui-hide">
                    <label class="layui-form-label">id</label>
                    <div class="layui-input-block">
                        <input autocomplete="off" class="layui-input" name="id" th:value="*{id}" type="text">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label required">任务名称</label>
                    <div class="layui-input-block">
                        <input autocomplete="off" class="layui-input" lay-verify="required" name="name" th:value="*{name}" type="text">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label required">对应指标id</label>
                    <div class="layui-input-block">
                        <input autocomplete="off" class="layui-input" lay-verify="required" name="targetid" th:value="*{targetid}" type="text">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label required">业务分类编号</label>
                    <div class="layui-input-block">
                        <input autocomplete="off" class="layui-input" disabled="disabled" lay-verify="required" name="typenum" th:value="*{typenum}" type="text">
                    </div>
                </div>
                <div class="layui-form-item" id="periodtypeItem">
                    <label class="layui-form-label">执行周期</label>
                    <div class="layui-input-block">
                        <select id="periodtype" name="periodtype" lay-verify="required" th:field="*{periodtype}">
                            <option value=""></option>
                            <option value="1">月度</option>
                            <option value="2">季度</option>
                            <option value="3">年度</option>
                        </select>
                    </div>
                </div>
                <div class="layui-form-item" id="typenumItem">
                    <label class="layui-form-label">业务分类编号</label>
                    <div class="layui-input-block">
                        <select id="enabled" name="enabled" lay-verify="required|typenum" th:field="*{enabled}">
                            <option value=""></option>
                            <option value="0">禁用</option>
                            <option value="1">启用</option>
                        </select>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">备注</label>
                    <div class="layui-input-block">
                        <input autocomplete="off" class="layui-input" lay-verify="" name="memo" th:value="*{memo}" type="text">
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div class="bottom">
        <div class="button-container">
            <button class="layui-btn layui-btn-normal layui-btn-sm" lay-filter="rpaTask-update" lay-submit=""
                    type="submit">
                <i class="layui-icon layui-icon-ok"></i>
                提交
            </button>
            <button class="layui-btn layui-btn-primary layui-btn-sm" type="reset">
                <i class="layui-icon layui-icon-refresh"></i>
                重置
            </button>
        </div>
    </div>
</form>
<th:block th:include="include :: footer"/>
<script>
    layui.use(['form', 'jquery'], function () {
        var form = layui.form;
        var $ = layui.jquery;

        var MODULE_PATH = rootPath + "/RpaTaskController/";

        form.on('submit(rpaTask-update)', function (data) {
            $.ajax({
                url: MODULE_PATH+'edit',
                data: JSON.stringify(data.field),
                dataType: 'json',
                contentType: 'application/json',
                type: 'post',
                success: function (result) {
                    if (result.code == 200) {
                        layer.msg(result.msg, {icon: 1, time: 1000}, function () {
                            parent.layer.close(parent.layer.getFrameIndex(window.name));//关闭当前页
                            parent.layui.table.reload("rpaTask-table");
                        });
                    } else {
                        layer.msg(result.msg, {icon: 2, time: 1000});
                    }
                }
            })
            return false;
        });
    })
</script>
<script>
</script>
</body>
</html>